package com.dyypdadmin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dyypdadmin.pojo.AppointmentRecords;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface AppointmentRecordsDao extends BaseMapper<AppointmentRecords> {

    // 查询所有预约记录
    @Select("SELECT * FROM appointmentrecords")
    List<AppointmentRecords> getAllAppointmentRecords();

    // 根据预约记录ID查询预约记录
    @Select("SELECT * FROM appointmentrecords WHERE appointment_pkid = #{appointment_pkid}")
    AppointmentRecords getAppointmentRecordsById(@Param("appointment_pkid") Integer appointment_pkid);

    // 插入预约记录
    @Insert("INSERT INTO appointmentrecords (user_pkid, pet_id, project_id, doctor_pkid,appointment_date, appointment_time,is_medical) " +
            "VALUES (#{user_pkid}, #{pet_id}, #{project_id}, #{doctor_pkid},now(),#{appointment_time},#{is_medical})")
    int insertAppointmentRecords(
            @Param("user_pkid") Integer user_pkid,
            @Param("pet_id") Integer pet_id,
            @Param("project_id") Integer project_id,
            @Param("doctor_pkid") Integer doctor_pkid,
            @Param("appointment_time") Date appointment_time,
            @Param("is_medical") Integer is_medical

    );

    // 更新预约记录
    @Update("UPDATE appointmentrecords SET user_pkid = #{appointmentRecords.user_pkid}, " +
            "pet_id = #{appointmentRecords.pet_id}, project_id = #{appointmentRecords.project_id}, " +
            "doctor_pkid = #{appointmentRecords.doctor_pkid}, appointment_time = #{appointmentRecords.appointment_time} " +
            "WHERE appointment_pkid = #{appointmentRecords.appointment_pkid}")
    int updateAppointmentRecords(@Param("appointmentRecords") AppointmentRecords appointmentRecords);

    // 删除预约记录
    @Delete("DELETE FROM appointmentrecords WHERE appointment_pkid = #{appointment_pkid}")
    int deleteAppointmentRecords(@Param("appointment_pkid") Integer appointment_pkid);


    //修改完成状态
    @Update("update appointmentrecords set appointment_status=#{status} where appointment_pkid = #{appointment_pkid}")
    int updateAppointment_status(@Param("appointment_pkid") Integer appointment_pkid,@Param("status") String status);

    @Select("select count(*) from appointmentrecords")
    int getAppointmentCounts();



}
